<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <!-- **练习1：用户登录状态显示**

- 创建一个用户登录状态切换组件
- 使用v-show控制登录/登出按钮的显示
- 使用v-show控制用户信息面板的显示 -->

    <div id="app">
        <h1>{{msg}}</h1>
        <span>{{textFont}}</span><br>
        <button @click='loginIn()' id="loginIn" v-show="!isLogin">登入</button>
        <button @click="loginOut()" id="loginOut" v-show="isLogin">登出</button>

    </div>
</body>

</html>
<script>
    let vue = new Vue({
        el: "#app",
        data: {
            msg: "Vue",
            // 初始化用户对象
            textFont: "文字初始",
            isLogin:false,
            user: {
                name: '',
                age: null
            }
        },
        methods: {
            loginIn(name, age) {
                this.isLogin =true
                this.user.name = "name";
                this.user.age = 18;
                this.textFont = `${this.user.name}，${this.user.age}`;
            },
            loginOut(name, age) {
                this.isLogin=false
                this.user.name = "name";
                this.user.age = 18;
                this.textFont = `${name}，${age}`;
            }
            
        }
    })

</script>